<?php defined('BASEPATH') OR exit('No direct script access allowed.');

/**
 * CodeIgniter Date Helpers
 *
 * @package        CodeIgniter
 * @subpackage    Helpers
 * @category    Helpers
 * @author Philip Sturgeon
 */

// ------------------------------------------------------------------------
function format_date($unix, $format = '')
{
    if ($unix == '' || !is_numeric($unix)) {
        $unix = strtotime($unix);
    }
    
    if (!$format) {
        $format = Settings::get('date_format');
    }

    return strstr($format, '%') !== FALSE
            ? ucfirst(utf8_encode(strftime($format, $unix))) //or? strftime($format, $unix)
            : date($format, $unix);
}

function get_date_formats()
{
    $date_formats = array(
        'd-m-Y',
        'd/m/Y',
        'Y/m/d',
        'Y-m-d',
        'm-d-Y',
        'm/d/Y',
    );
    $arr = array();
    foreach ($date_formats as $date_format) {
        $arr[] = $date_format . '=' . date($date_format);
    }
    return $arr;
}